//给定一个整数 num，将其转化为 7 进制，并以字符串形式输出。 
//
// 
//
// 示例 1: 
//
// 
//输入: num = 100
//输出: "202"
// 
//
// 示例 2: 
//
// 
//输入: num = -7
//输出: "-10"
// 
//
// 
//
// 提示： 
//
// 
// -10⁷ <= num <= 10⁷ 
// 
// Related Topics 数学 👍 127 👎 0

package leetcode.editor.cn;
public class _504_Base7 {
    public static void main(String[] args) {
        Solution solution = new _504_Base7().new Solution();
        System.out.println(solution.convertToBase7(0));
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public String convertToBase7(int num) {

//        StringBuilder sb = new StringBuilder();
        String res = "";
        int tmp = Math.abs(num);
        while (tmp != 0) {
            res += tmp % 7;
            tmp /= 7;
        }
        StringBuilder sb = new StringBuilder(res);
        if (num < 0) sb.append("-");
        sb.reverse();


        return sb.toString();
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}